All Questions
45 questions
1vote
2answers
900views
Jasmine spyOn not working properly on AngularJS directive
I'm working on an AngularJS app and I'm facing some problems with Jasmine's SpyOn in a concrete directive. The directive is quite simple, just call a service's method and when it resolves/rejects the ...
1vote
1answer
316views
Angular Directive function not being called in Unit Testing
I built a new directive in Angular (1.2.29) and I am trying to test it using karma, however I am having some problems when checking if the field is invalid, it seems it's always valid. Here is my ...
1vote
0answers
39views
Unit testing angular directive with link function
My link function of a directive shows some dummy mock ask for external data (promise). Whenever the promise resolves or rejectes dummy data is hidden Is there a way to unit test directive, checking ...
1vote
1answer
2kviews
Unit Testing Angular Attribute Directive
I am having some problems testing an AngularJS (1.5) Attribute restricted Directive. See the below example directive and following unit test, of which produces a broken unit test. Directive (...
2votes
1answer
586views
Unit tests for Angular js directive for ui-mask
I have a directive called maskUI .directive('uiMask', function () { return { template: '<input ui-mask="{{maskPattern}}"/>', replace: true, scope: true, ...
0votes
1answer
65views
Testing angularjs directive for attribute
I have the following directive which works fine and now I need to unit test it, (() => { angular .module('app.utilities') .directive('allowPattern', allowPatternDirective); function ...
0votes
1answer
61views
unit testing directive and isolatedScope not a function
I am trying to unit test a directive that was previously written and for my first unit test all I want to do is check a variable inside the scope of the directive. However, every time I try to run ...
0votes
1answer
598views
How to write unit test for angularjs Attribute type directives in jasmine
I have some directives without using any template/templateUrl. How can i write a unit test for this directive. The below code is my directive. var app = angular.module('SampleDirective'); app....
3votes
1answer
988views
How do I test the HTML pointed to by the templateUrl of an angular directive?
I have a directive: app/controllers/battle.js angular.module('myModule') .controller('myController', ['$scope', function($scope){ $scope.sayHello = function(){console.log('hello');}; }])...
1vote
0answers
254views
Testing linked function in angular directive doesn't work
I'm quite new to the unit-testing using jasmine and karma. I'm trying to test the function that's in the link in the directive. It's being called on the click event that I'm trying to get. Note that I'...
1vote
1answer
682views
AngularJS unit test Directive's attribute value
I have a directive that looks like this: <foo bar="5"></foo> where bar is an attribute and not defined in the scope property of the DDO. How can I write a unit test to assert that the ...
1vote
1answer
1kviews
Unit Testing Custom File Input Directive
I am having a huge problem with getting a unit test to work for a custom file directive for angular 1.5.0 and Jasmine 2.4, I have looked at How to provide mock files to change event of <input ...
0votes
1answer
63views
unit testing of directive with default scope
I am trying to unit test a directive which has default scope(scope:false) but I am not able to inject dependency of its controller. var MyApp = angular.module('MyApp',['MyDirectives','MyServices','...
3votes
0answers
5kviews
Jasmine cannot read property of undefined
I usually don't post the whole stack trace, but I've been having this problem with one individual unit test and it's driving me nuts. I've rewritten it at least 10 different times and 20 different ...
2votes
1answer
321views
Angular unit testing initialize "nameless" controller in directive
I'm curious as to how I would go about unit testing what I think is an anonymous controller inside of a directive. directive.js app.directive('directive', function() { var controller = ['...